#ifndef __UTILITY_H__
#define __UTILITY_H__

#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>

#define __MY_DEBUG__

namespace Utility
{
	/*
	 * try {
	 *     ...
	 * } catch (MyException ex) {
	 *     ...
	 * }
	 */
	class MyException {
	private:
		std::string		m_Msg;
		int				m_Line;
		std::string		m_File;
	public:
		MyException(std::string in_Msg, int in_Line, std::string in_File)
			: m_Msg(in_Msg)
			, m_Line(in_Line)
			, m_File(in_File) { }
	};

	#define ThrowException(msg)														\
		throw Utility::MyException(msg, __LINE__, __FILE__);

#ifdef __MY_DEBUG__
	#define ASSERT(condition, msg)														\
		if (!(condition))	{															\
			printf("error: %s, line: %d, file: %s", msg, __LINE__, __FILE__);				\
			ThrowException(std::string(msg));											\
		}
#else 
	#define ASSERT(condition, msg)														\
		if (!(condition))	{															\
			printf("error: %s, line: %d, file: %s", msg, __LINE__, __FILE__);				\
		}
#endif
	#define INF 1e6

	inline bool DoubleCmp(double i, double j, double eps = 1e-6)
	{
		return fabs(i - j) < fabs(eps);
	}

	std::string IntToString(int num);

}

#endif ///> end of __UTILITY_H__